package cn.pugle.oj.leetcode;

import cn.pugle.oj.catalog.Unknown;

/**
 * https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum/
 * <p>
 * We are given an array A of positive integers, and two positive integers L and R (L <= R).
 * <p>
 * Return the number of (contiguous, non-empty) subarrays such that the value of the maximum array element in that subarray is at least L and at most R.
 *
 * 一开始想到滑动窗口思路, 好像有点问题, 改为dp思路
 * 错误写法
 */
public class LC795  implements Unknown {
    /**
     * Example :
     * Input:
     * A = [2, 1, 4, 3]
     * L = 2
     * R = 3
     * Output: 3
     * Explanation: There are three subarrays that meet the requirements: [2], [2, 1], [3].
     * <p>
     * 22243
     * 222143
     */
    public int numSubarrayBoundedMax(int[] A, int L, int R) {
        int l, r = 0;
        int num = 0;
        int curMax;
        while (r < A.length) {
            if (A[r] <= R && A[r] >= L) {
                num++;
            }
        }

        return -1;
    }
}
